//package com.daocao.hua.activity;
//
//import android.content.Intent;
//import android.graphics.Color;
//import android.graphics.drawable.Drawable;
//import android.os.Build;
//import android.os.Bundle;
//import android.text.Spannable;
//import android.text.SpannableStringBuilder;
//import android.text.style.ForegroundColorSpan;
//import android.util.DisplayMetrics;
//import android.util.Log;
//import android.view.View;
//import android.view.ViewGroup;
//import android.view.WindowManager;
//import android.widget.ImageView;
//import android.widget.LinearLayout;
//import android.widget.RelativeLayout;
//import android.widget.TextView;
//
//import com.bumptech.glide.Glide;
//import com.daocao.hua.R;
//import com.daocao.hua.api.callback.ApplyStatusContract;
//import com.daocao.hua.api.requestInfo.NewApplyForRequest;
//import com.daocao.hua.constant.Const;
//import com.daocao.hua.event.ChangeHomePagerEvent;
//import com.daocao.hua.model.ApplyStatusModel;
//import com.daocao.hua.model.BankListModel;
//import com.daocao.hua.util.DisplayUtil;
//import com.daocao.hua.util.PreferenceUtils;
//import com.daocao.hua.util.UI;
//import com.daocao.hua.util.Util;
//import com.daocao.hua.view.BottomIconText;
//import com.readystatesoftware.systembartint.SystemBarTintManager;
//
//import org.greenrobot.eventbus.EventBus;
//
//import butterknife.BindDrawable;
//import butterknife.BindView;
//import butterknife.ButterKnife;
//import butterknife.OnClick;
//import butterknife.Unbinder;
//import cn.sharesdk.framework.ShareSDK;
//
///**
// * Created by xsooy-pc on 2017/7/11.
// */
//
//public class NewApplyForActivity extends BaseActivity implements ApplyStatusContract.View {
//    @BindView(R.id.img_banner)
//    ImageView imgBanner;
//    @BindView(R.id.txt_fail_status)
//    TextView txtFailStatus;
//    @BindView(R.id.txt_fail_tips)
//    TextView txtFailTips;
//    @BindView(R.id.txt_fail_content)
//    TextView txtFailContent;
//    @BindView(R.id.btn_fail_back)
//    BottomIconText btnFailBack;
//    @BindView(R.id.btn_fail_offtime_job)
//    BottomIconText btnFailOfftimeJob;
//    @BindView(R.id.layout_fail)
//    LinearLayout layoutFail;
//    @BindView(R.id.txt_status)
//    TextView txtStatus;
//    @BindView(R.id.txt_tips)
//    TextView txtTips;
//    @BindView(R.id.txt_apply_num)
//    TextView txtApplyNum;
//    @BindView(R.id.txt_xinyong_num)
//    TextView txtXinyongNum;
//    @BindView(R.id.btn_back)
//    BottomIconText btnBack;
//    @BindView(R.id.btn_identity)
//    BottomIconText btnIdentity;
//    @BindView(R.id.layout_ing_success)
//    LinearLayout layoutIngSuccess;
//    @BindView(R.id.layout_total)
//    RelativeLayout layoutTotal;
//    @BindView(R.id.view_bottom)
//    View viewBottom;
//    @BindView(R.id.txt_info)
//    TextView txtInfo;
//    @BindView(R.id.txt_fail_content_sec)
//    TextView txtFailContentSec;
//    @BindDrawable(R.mipmap.img_apply_job)
//    Drawable imgApplyJob;
//    @BindView(R.id.layout_top)
//    LinearLayout layoutTop;
//    @BindView(R.id.img_fail_banner)
//    ImageView imgFailBanner;
//    @BindView(R.id.txt_fail_info)
//    TextView txtFailInfo;
//    @BindView(R.id.layout_fail_icon)
//    LinearLayout layoutFailIcon;
//    private Unbinder unbiner;
//    private NewApplyForRequest api;
//    private ApplyStatusModel.DataBean.ShareBean share;
//    private int d_status;
//
//    @Override
//    protected void onCreate(Bundle savedInstanceState) {
//        super.onCreate(savedInstanceState);
//        setContentView(R.layout.activity_new_applyfor);
//        unbiner = ButterKnife.bind(this);
//        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
//            //透明状态栏
//            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
//            //透明导航栏
//            SystemBarTintManager tintManager = new SystemBarTintManager(this);
//            tintManager.setStatusBarTintColor(Color.TRANSPARENT);
//            tintManager.setNavigationBarTintColor(Color.parseColor("#000000"));
//            tintManager.setStatusBarTintEnabled(true);
//            tintManager.setNavigationBarTintEnabled(true);
//        }
//        init();
//
//
//    }
//
//
//    private void init() {
//        api = NewApplyForRequest.create();
//        api.attachView(this);
////        ShareSDK.initSDK(this);
//        api.getApplyFor(PreferenceUtils.getString(this, "deal_id", ""));
//    }
//
//
//    private void setImage(float aoto) {
//        if (d_status == 3) {
//            DisplayMetrics dm = Util.getDisplayMetrics(this);
//            ViewGroup.LayoutParams lp = imgFailBanner.getLayoutParams();
//            lp.width = (int) (dm.widthPixels * 0.67);
//            lp.height = (int) (lp.width * aoto);
//            imgFailBanner.setLayoutParams(lp);
//        } else {
//            DisplayMetrics dm = Util.getDisplayMetrics(this);
//            ViewGroup.LayoutParams lp = imgBanner.getLayoutParams();
//            lp.width = (int) (dm.widthPixels * 0.67);
//            lp.height = (int) (lp.width * aoto);
//            imgBanner.setLayoutParams(lp);
//        }
//    }
//
//
//    @OnClick({R.id.btn_back, R.id.btn_identity, R.id.btn_weixin_moment, R.id.btn_weixin, R.id.btn_qq, R.id.btn_weibo, R.id.btn_fail_back, R.id.btn_fail_offtime_job})
//    public void onViewClicked(View view) {
//        switch (view.getId()) {
//            case R.id.btn_back:
//                finish();
//                break;
//            case R.id.btn_identity:
//                if (d_status == 2) {
//                    Util.startActivity(this, V3InviteFriendsActivity.class);
//                } else if (d_status == 1) {
//                    EventBus.getDefault().post(new ChangeHomePagerEvent(1));
//                }
//
//                break;
//            case R.id.btn_weixin_moment:
//
//                if (share != null) {
//                    api.share(1, share.description, share.image, share.title, share.url);
//                }
//                break;
//            case R.id.btn_weixin:
//                if (share != null) {
//                    api.share(2, share.description, share.image, share.title, share.url);
//                }
//                break;
//            case R.id.btn_qq:
//                if (share != null) {
//                    api.share(3, share.description, share.image, share.title, share.url);
//                }
//                break;
//            case R.id.btn_weibo:
//                if (share != null) {
//                    api.share(4, share.description, share.image, share.title, share.url);
//                }
//                break;
//            case R.id.btn_fail_back:
//                finish();
//                break;
//            case R.id.btn_fail_offtime_job:
//                Util.startActivity(this, V3InviteFriendsActivity.class);
//                break;
//        }
//    }
//
//    @Override
//    protected void onDestroy() {
//        super.onDestroy();
//        unbiner.unbind();
//        api.detachView();
//
//    }
//
//    @Override
//    public void showError() {
//
//    }
//
//    @Override
//    public void complete() {
//
//    }
//
//    @Override
//    public void onRequestStart() {
//
//    }
//
//    private void initHeight() {
//        if (d_status == 3) {
//            layoutTotal.post(new Runnable() {
//                @Override
//                public void run() {
//                    DisplayMetrics dm = Util.getDisplayMetrics(NewApplyForActivity.this);
//                    int scrollHight = dm.heightPixels;
//                    int layoutHeight = txtFailInfo.getHeight();
//                    int layoutTop = layoutFailIcon.getBottom();
////                    Log.i("dasdasdadadsa", scrollHight + "," + layoutHeight + "," + layoutTop + "," + imgBanner.getHeight() + "," + imgBanner.getBottom() + "," + imgBanner.getTop() + "," + txtStatus.getTop());
//                    ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) txtFailInfo.getLayoutParams();
//                    if (layoutHeight + layoutTop < scrollHight) {
//                        params.topMargin = scrollHight - (layoutTop + layoutHeight) - 10;
//                        txtFailInfo.setLayoutParams(params);
//                    }
//                }
//            });
//        } else {
//            layoutTotal.post(new Runnable() {
//                @Override
//                public void run() {
//                    DisplayMetrics dm = Util.getDisplayMetrics(NewApplyForActivity.this);
//                    int scrollHight = dm.heightPixels;
//                    int layoutHeight = txtInfo.getHeight();
//                    int layoutTop = viewBottom.getBottom();
////                Log.i("dasdasdadadsa", scrollHight + "," + layoutHeight + "," + layoutTop + "," + imgBanner.getHeight() + "," + imgBanner.getBottom() + "," + imgBanner.getTop() + "," + txtStatus.getTop());
//                    ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) txtInfo.getLayoutParams();
//                    if (layoutHeight + layoutTop + 10 < scrollHight) {
//                        params.topMargin = scrollHight - (layoutTop + layoutHeight) - 10;
//                        txtInfo.setLayoutParams(params);
//                    }
//                }
//            });
//        }
//
//
//    }
//
//    @Override
//    public void getApplyForSuccess(ApplyStatusModel data) {
//        ApplyStatusModel.DataBean item = data.data;
////        0 - 申请中，1 - 等待审核，2 - 已审核，等待放款，3 - 审核失败， 4 - 还款中，5 - 已还清
////        item.deal_status = 3;
//        d_status = item.deal_status;
//
//        if (item.deal_status == 3) {
//            layoutFail.setVisibility(View.VISIBLE);
//            layoutIngSuccess.setVisibility(View.GONE);
////            item.failed = new ApplyStatusModel.DataBean.FailedBean();
////            item.failed.days = "7";
////            item.failed.p1 = "别气馁，欧巴君赠送你18888元奖金";
////            item.failed.p2 = "骗你的，哈哈";
//            txtFailTips.setText("花毛线认为您的综合评分不足，" + item.failed.days + "天后再尝试");
//            txtFailContent.setText(item.failed.p1);
//            txtFailContentSec.setText(item.failed.p2);
//            String str = item.failed.p1;
//            String str2 = "";
//            if (str != null && !"".equals(str)) {
//                for (int i = 0; i < str.length(); i++) {
//                    if (str.charAt(i) >= 48 && str.charAt(i) <= 57) {
//                        str2 += str.charAt(i);
//                    }
//                }
//                SpannableStringBuilder builder = new SpannableStringBuilder(txtFailContent.getText().toString());
//
////ForegroundColorSpan 为文字前景色，BackgroundColorSpan为文字背景色
//                int index = str.indexOf(str2);
//                ForegroundColorSpan redSpan = new ForegroundColorSpan(0xFFFA2600);
//                builder.setSpan(redSpan, index, index + str2.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
//                txtFailContent.setText(builder);
//            }
//            float aotu = item.banner.height / item.banner.width;
//            setImage(aotu);
//            Glide.with(this).load(item.banner.image).into(imgFailBanner);
//            imgFailBanner.setOnClickListener(new View.OnClickListener() {
//                @Override
//                public void onClick(View v) {
//                    Intent intent = new Intent(v.getContext(), LookPayProcessActivity.class);
//                    intent.putExtra(Const.KEY.PROCESS_URL, item.banner.url);
//                    startActivity(intent);
//                }
//            });
//            initHeight();
//        } else {
//            layoutFail.setVisibility(View.GONE);
//            layoutIngSuccess.setVisibility(View.VISIBLE);
//            txtApplyNum.setText(item.number + "人");
//            txtXinyongNum.setText("+" + item.point);
//            if (item.deal_status == 2) {
//                txtStatus.setText("审核成功");
//                txtInfo.setText("兼职来赚钱，月入上万元");
////                int textSize = DisplayUtil.sp2px(this, 16);
//                btnIdentity.setTextString("兼职赚钱", 16, 1);
//                btnIdentity.setDrawable(imgApplyJob, DisplayUtil.dip2px(this, 31), DisplayUtil.dip2px(this, 34));
//                if(item.bankcard.length()>=4){
//                    txtTips.setText("资金将在2小时内转入尾号" + item.bankcard.substring(item.bankcard.length()-4) + "银行卡");
//                }
//            }
//
//
//            float aotu = item.banner.height / item.banner.width;
//            setImage(aotu);
//            Glide.with(this).load(item.banner.image).into(imgBanner);
//
//        }
//
//        initHeight();
//        share = item.share;
//
//
//    }
//
//
//}
